package dcedit.factories;

// Import Java SDK Classes
import java.awt.*;
import javax.swing.*;

// Import Application Classes
import dcedit.util.*;

/** PanelFactory class */
public class PanelFactory {
   /** Private Constructor */
   private PanelFactory() {} // constructor

   /** createAppPanel method */
   public static JPanel createAppPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.Y_AXIS);

      PANEL.setLayout(LAYOUT);
      PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD));
      PANEL.add(createIconPanel());
      PANEL.add(createTabPanel());
      PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD));

      return PANEL;
   } // END createAppPanel

   /** createIconPanel method */
   public static JPanel createIconPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.X_AXIS);
      final Dimension SIZE = new Dimension(800, 60);
      final Dimension MAZ_SIZE = new Dimension(4000, 60);
      final JSeparator VERTICAL_BAR = new JSeparator(SwingConstants.VERTICAL);

      PANEL.setLayout(LAYOUT);
      Util.setComponentSizes(PANEL, SIZE, false, false);
      PANEL.setMaximumSize(MAZ_SIZE);
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(BtnFactory.createAddBtn());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(BtnFactory.createOpenBtn());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(BtnFactory.createSaveBtn());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(BtnFactory.createDeleteBtn());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(VERTICAL_BAR);
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(createFontPanel());
      PANEL.add(Box.createHorizontalGlue());

      return PANEL;
   } // END createIconPanel

   /** createFontPanel */
   public static JPanel createFontPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.X_AXIS);
      final Dimension SIZE = new Dimension(3900, 60);

      PANEL.setLayout(LAYOUT);
      Util.setComponentSizes(PANEL, SIZE, false, true);
      PANEL.add(createLanguageAndFontPanel());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(createBoldItalicAutoIndentPanel());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(createFgBgHlFontColorPanel());
      PANEL.add(Box.createHorizontalGlue());

      return PANEL;
   } // END createFontPanel

   /** createLanguageAndFontPanel method */
   public static JPanel createLanguageAndFontPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.Y_AXIS);

      PANEL.setLayout(LAYOUT);
      PANEL.add(ComboBoxFactory.createLanguageList());
      PANEL.add(ComboBoxFactory.createFontNameList());
      PANEL.add(ComboBoxFactory.createFontSizeList());

      return PANEL;
   } // END createLanguageAndFontPanel

   /** createBoldItalicAutoIndentPanel method */
   public static JPanel createBoldItalicAutoIndentPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.Y_AXIS);

      PANEL.setLayout(LAYOUT);
      PANEL.add(BtnFactory.createBoldBtn());
      PANEL.add(BtnFactory.createItalicBtn());
      PANEL.add(BtnFactory.createAutoIndentBtn());

      return PANEL;
   } // END createBoldItalicAutoIndentPanel

   /** createFgBgHlFontColorPanel method */
   public static JPanel createFgBgHlFontColorPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.Y_AXIS);

      PANEL.setLayout(LAYOUT);
      PANEL.add(BtnFactory.createFontColorBtn());
      PANEL.add(BtnFactory.createBackgroundColorBtn());
      PANEL.add(BtnFactory.createHighlightColorBtn());

      return PANEL;
   } // END createFgBgHlFontColorPanel

   /** createTabPanel method */
   public static JPanel createTabPanel() {
      final JPanel PANEL = new JPanel();
      final BoxLayout LAYOUT = new BoxLayout(PANEL, BoxLayout.X_AXIS);

      PANEL.setLayout(LAYOUT);
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));
      PANEL.add(createTabbedPane());
      PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD));

      return PANEL;
   } // END createTabPanel

   /** createTabbedPane method */
   public static JTabbedPane createTabbedPane() {
      Util.addNewTab();
      Constants.TAB_PANE.addMouseListener(ActionFactory.createTabPaneListener());
      return Constants.TAB_PANE;
   } // END createTabbedPane
} // END class PanelFactory